<template>
  <div class="Respect">
    <Head msg="信誉管理"></Head>
    <div class="respect-main">
      <div class="respect-list">
        <div class="respect-title">信誉值</div>
        <div>{{ numdata.rep_point }}</div>
      </div>
      <div style="width: 1px;height: 50px;background: white"></div>
      <div class="respect-list">
        <div class="respect-title">举报数</div>
        <div>{{ numdata.count }}</div>
      </div>
    </div>
    <cube-scroll
      ref="scroll"
      :data="list"
      :options="options"
      @pulling-up="dealerRep"
      class="record-main"
    >
      <div class="record-list" v-for="item in list" :key="item.id">
        <div class="record-title" v-html="item.note"></div>
        <div class="record-time">投诉时间：{{ item.create_time }}</div>
      </div>
      <Notice msg="暂无投诉记录" :notice="list.length"></Notice>
    </cube-scroll>
  </div>
</template>

<script lang="ts">
import { Component } from 'vue-property-decorator';
import Sence from '../sence/Sence';
// import HelloWorld from '@/components/HelloWorld.vue'; // @ is an alias to /src
import Head from '@/components/Head.vue';
import Notice from '@/components/Notice.vue';

@Component({
  components: {
    Head,
    Notice,
  },
})
export default class Respect extends Sence {
  public id: any = 0;
  public numdata: any = {}; // 信誉数据
  public list: any = []; // 举报记录
  public page: any = 1; // 页数
  public size: any = 10; /** 记录数 */
  public options: object = {
    pullUpLoad: true,
  }; // 上拉加载

  public mounted(): void {
    if (this.$route.query.id) {
      this.id = this.$route.query.id;
    }
    this.dealerRep();
  }

  public dealerRep(): void {
    this.post('api/v1/dealerRep', {
      dealer_id: this.id,
      page: this.page,
      size: this.size,
    }).then((res: any) => {
      this.numdata = res.data;
      this.list = [...this.list, ...res.data.list];
      this.page += 1;
      if (res.data.list.length < this.size) {
        this.options = {
          pullUpLoad: false,
        };
      }
    });
  }
}
</script>

<style scoped lang="stylus">
* {
  font-size: 14px;
}

.record-main {
  display: flex;
  flex-direction: column;
  height: calc(100vh - 50px - 45px - 20px);
}

.record-list {
  display: flex;
  flex-direction: column;
  padding: 10px;
  border-bottom: 1px solid #ccc;
}

.respect-main {
  display: flex;
  flex-direction: row;
  justify-content: space-between;
  background: #4876ff;
  padding: 10px 0;
}

.respect-list {
  width: 49vw;
  display: flex;
  flex-direction: column;
  justify-content: space-around;
  height: 50px;

  > div {
    color: white;
  }
}

.respect-title {
  color: #f2f2f2 !important;
}

.record-title {
  font-size: 14px;
  text-align: left;
  word-break: break-all;
  line-height: 19px;
}

.record-time {
  margin-top: 8px;
  color: #808080;
  font-size: 14px;
  text-align: left;
}
</style>
